package com.ruoyi.project.tugboat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.tugboat.domain.TMqttMsgConvert;
import com.ruoyi.project.tugboat.service.ITMqttMsgConvertService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 转换后的消息主Controller
 * 
 * @author ruoyi
 * @date 2024-01-04
 */
@RestController
@RequestMapping("/system/convert")
public class TMqttMsgConvertController extends BaseController
{
    @Autowired
    private ITMqttMsgConvertService tMqttMsgConvertService;

    /**
     * 查询转换后的消息主列表
     */
    @PreAuthorize("@ss.hasPermi('system:convert:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMqttMsgConvert tMqttMsgConvert)
    {
        startPage();
        List<TMqttMsgConvert> list = tMqttMsgConvertService.selectTMqttMsgConvertList(tMqttMsgConvert);
        return getDataTable(list);
    }

    /**
     * 导出转换后的消息主列表
     */
    @PreAuthorize("@ss.hasPermi('system:convert:export')")
    @Log(title = "转换后的消息主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TMqttMsgConvert tMqttMsgConvert)
    {
        List<TMqttMsgConvert> list = tMqttMsgConvertService.selectTMqttMsgConvertList(tMqttMsgConvert);
        ExcelUtil<TMqttMsgConvert> util = new ExcelUtil<TMqttMsgConvert>(TMqttMsgConvert.class);
        util.exportExcel(response, list, "转换后的消息主数据");
    }

    /**
     * 获取转换后的消息主详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:convert:query')")
    @GetMapping(value = "/{msgConvertId}")
    public AjaxResult getInfo(@PathVariable("msgConvertId") Long msgConvertId)
    {
        return success(tMqttMsgConvertService.selectTMqttMsgConvertByMsgConvertId(msgConvertId));
    }

    /**
     * 新增转换后的消息主
     */
    @PreAuthorize("@ss.hasPermi('system:convert:add')")
    @Log(title = "转换后的消息主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMqttMsgConvert tMqttMsgConvert)
    {
        return toAjax(tMqttMsgConvertService.insertTMqttMsgConvert(tMqttMsgConvert));
    }

    /**
     * 修改转换后的消息主
     */
    @PreAuthorize("@ss.hasPermi('system:convert:edit')")
    @Log(title = "转换后的消息主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMqttMsgConvert tMqttMsgConvert)
    {
        return toAjax(tMqttMsgConvertService.updateTMqttMsgConvert(tMqttMsgConvert));
    }

    /**
     * 删除转换后的消息主
     */
    @PreAuthorize("@ss.hasPermi('system:convert:remove')")
    @Log(title = "转换后的消息主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{msgConvertIds}")
    public AjaxResult remove(@PathVariable Long[] msgConvertIds)
    {
        return toAjax(tMqttMsgConvertService.deleteTMqttMsgConvertByMsgConvertIds(msgConvertIds));
    }
}
